/*
 果园里的树排列成矩阵。它们的x和y坐标均是1~99的整数。输入若干个三角形，依次统计每一个三角形内部和边界上共有多少棵树。
 样例输入：
 1.5 1.5    1.5 6.8    6.8 1.5
 10.7 6.9   8.5 1.5    14.5 1.5
 样例输出：
 15
 17
 -------------------------------------------------------------
注意：本题计算浮点数会产生误差，导致答案错误，应尽量避免浮点数计算或者解决误差问题。
下面的程序是将输入数据乘以1000来将小数位不大于3的数转换成整数。
 */
package com.yuan.algorithms.Algorithm_1;

import java.util.Scanner;

public class 果园里的树 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int x1, y1, x2, y2, x3, y3;
            x1 = (int)(sc.nextDouble()*1000);
            y1 = (int)(sc.nextDouble()*1000);
            x2 = (int)(sc.nextDouble()*1000);
            y2 = (int)(sc.nextDouble()*1000);
            x3 = (int)(sc.nextDouble()*1000);
            y3 = (int)(sc.nextDouble()*1000);
            int allArea = triangleArea(x1, y1, x2, y2, x3, y3);
            int num = 0;//三角形内树的数量
            for (int i = 1; i <= 99; i++) {
                for (int j = 1; j <= 99; j++) {
                    int tempArea = triangleArea(i*1000, j*1000, x1, y1, x2, y2) + triangleArea(i*1000, j*1000, x1, y1, x3, y3) + triangleArea(i*1000, j*1000, x2, y2, x3, y3);
                    if (tempArea == allArea) {
                        num++;
                    }
                }
            }
            System.out.println(num);
        }
    }

    public static int triangleArea(int x1, int y1, int x2, int y2, int x3, int y3) {
        //返回三角形面积的两倍
        int Area = x1 * y2 + x2 * y3 + x3 * y1 - x1 * y3 - x2 * y1 - x3 * y2;
        return Area < 0 ? Area * -1 : Area;
    }
}
